from django.db import models

class MovieFile(models.Model):
	file_name = models.CharField(max_length = 200)
	added = models.DateTimeField(auto_now_add = True)
	
	def __unicode__(self):
		return self.file_name

class Movie(models.Model):
	moviefile = models.ForeignKey(MovieFile)
	imdb_id = models.CharField(max_length = 100)
	title = models.TextField()
	title_long = models.TextField()
	title_cano = models.TextField()
	title_long_cano = models.TextField()
	year = models.IntegerField(null = True)
	cover_url = models.TextField()
	imdb_rating = models.FloatField(null = True)
	mpaa_warning = models.CharField(max_length = 400)
	genre = models.ManyToManyField("Genre")
	mpaa_rating = models.ManyToManyField("Certificate")
	runtime = models.IntegerField(null = True)	
	active = models.BooleanField(default = False)
	
	def __unicode__(self):
		return self.title

class Genre(models.Model):
	name = models.CharField(max_length = 200)
	
	def __unicode__(self):
		return self.name
	
class Plot(models.Model):
	text = models.TextField()
	author = models.CharField(max_length = 200)
	movie = models.ForeignKey(Movie)
	
	def __unicode__(self):
		return self.author + ": " + self.text
		
class Certificate(models.Model):
	rating = models.CharField(max_length = 10)
	country = models.CharField(max_length = 10)
	
	def __unicode__(self):
		return self.rating
